package org.karelun.gef.actions;

import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.RetargetAction;
import org.karelun.gef.helper.ConstantMessages;
import org.karelun.gef.helper.ImageResource;

public class EditorActionFactory {
	
	public static final ActionFactory ADDATTRIBUTE=new ActionFactory("org.karelun.gef.createAttrAction"){ //$NON-NLS-1$
		public IWorkbenchAction create(IWorkbenchWindow window) {
			if(window==null)
				throw new IllegalArgumentException();
			RetargetAction action = new RetargetAction(getId(),ConstantMessages.AddAttrAction_Text);
			action.setToolTipText(ConstantMessages.AddAttrAction_toolTip);
			window.getPartService().addPartListener(action);
			action.setImageDescriptor(ImageResource.getImageDesc(ImageResource.ATTRIBUTE));
			return action;
		}
	};
	
	public static final ActionFactory ADDMETHOD=new ActionFactory("org.karelun.gef.createMethodAction"){ //$NON-NLS-1$
		public IWorkbenchAction create(IWorkbenchWindow window) {
			if(window==null)
				throw new IllegalArgumentException();
			RetargetAction action = new RetargetAction(getId(),ConstantMessages.AddMethodAction_Text);
			action.setToolTipText(ConstantMessages.AddMethodAction_toolTip);
			window.getPartService().addPartListener(action);
			action.setImageDescriptor(ImageResource.getImageDesc(ImageResource.METHOD));
			return action;
		}
	};
}
